package com.imooc.bigdata.hadoop.mr.project.Utils;/**
 * Created by luochangyong on 2019/8/15.
 */

import lombok.Data;
import org.apache.commons.collections.MapUtils;

import java.util.HashMap;
import java.util.Map;

import static com.amazonaws.services.ecs.model.UlimitName.Data;

/**
 * 模拟解析ip
 */
public class IpParser {
    public static Map<String, RegionInfo> regionInfoMap = new HashMap<String, RegionInfo>(8);

    static {
        RegionInfo regionInfo1 = new IpParser().new RegionInfo("中国", "广东省","广州市");
        RegionInfo regionInfo2 = new IpParser().new RegionInfo("中国", "广西省", "百色市");
        RegionInfo regionInfo3 = new IpParser().new RegionInfo("中国", "湖南省", "长沙市");
        IpParser.regionInfoMap.put("111.111.111.111", regionInfo1);
        IpParser.regionInfoMap.put("222.222.222.222", regionInfo2);
        IpParser.regionInfoMap.put("333.333.333.333", regionInfo3);
    }

    public static RegionInfo analyseIp(String ip){
        return IpParser.regionInfoMap.get(ip);
    }

    @Data
    public class RegionInfo{
        private String country;
        private String province;
        private String city;

        public RegionInfo(String country, String province, String city){
            this.country = country;
            this.province = province;
            this.city = city;
        }
    }
}